package com.moyun.zbmy.zizhou.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.moyun.zbmy.zizhou.R;
import com.moyun.zbmy.zizhou.beans.SubscriptionNoTypeBean;
import com.moyun.zbmy.zizhou.ui.adapter.holder.SubscriptionNoHomeTypeListHolder;
import com.moyun.zbmy.zizhou.ui.adapter.holder.SubscriptionNoTypeHolder;
import com.moyun.zbmy.zizhou.ui.utils.GlideUtil;
import com.ruihang.generalibrary.beans.ShareItem;
import com.ruihang.generalibrary.ui.adapter.BaseAbstractAdapter;
import com.ruihang.generalibrary.ui.adapter.holder.ShareHolder;

import java.util.ArrayList;
import java.util.List;

public class SubscriptionNoHomeTypeAdapter extends BaseAbstractAdapter<SubscriptionNoTypeBean> {

    private Context context;
    private List<SubscriptionNoTypeBean> dataList = new ArrayList<>();
    private OnHomeSubscriptionNoTypeClickListener listener;

    public SubscriptionNoHomeTypeAdapter(Context context) {
        super(context);
    }

    public SubscriptionNoHomeTypeAdapter(Context context, List<SubscriptionNoTypeBean> dataList, OnHomeSubscriptionNoTypeClickListener clickListener) {
        super(context, dataList);
        this.context = context;
        this.listener = clickListener;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        SubscriptionNoHomeTypeListHolder viewHolder = null;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_subscription_no_home_type, viewGroup, false);
            viewHolder = new SubscriptionNoHomeTypeListHolder(view);
        } else {
            viewHolder = (SubscriptionNoHomeTypeListHolder) view.getTag();
        }
        final SubscriptionNoTypeBean info = datas.get(i);
        viewHolder.type_title.setText(info.getChannelName());

        GlideUtil.getGlideWith11DefNoFit(context, info.getChannelImg()).centerCrop().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(viewHolder.type_img);

        viewHolder.itemLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != listener) {
                    listener.OnHomeSubscriptionNoTypeClick(i);
                }
            }
        });
        return view;
    }


    @Override
    public int getItemViewType(int position) {
        return 0;//dataList.get(position).getDataViewType();
    }

    @Override
    public int getCount() {
        return super.getCount();
    }

    public interface OnHomeSubscriptionNoTypeClickListener {
        void OnHomeSubscriptionNoTypeClick(int  position);
    }


}
